const baseConfig = require('./webpack.base.config.js')
const { merge } = require('webpack-merge');
const webpack = require('webpack');


// 合并配置
module.exports = merge(baseConfig, {
  mode: 'development',
  devtool: 'cheap-module-source-map',

  // 插件
  plugins: [
    new webpack.DefinePlugin({
      SERVER_URL: JSON.stringify('/server'),

    }),

  ],

  // 启动开发服务器
  devServer: {
    host: 'zmaolong.cn',
    port: 80,
    open: true,
    historyApiFallback: true,

    proxy: [
      // TODO 后端配置了跨域，但是前端不生效
      {
        context: ['/server'],
        target: 'http://api.zmaolong.cn:8088',
        pathRewrite: { '^/server': '' },
      },
    ]
  },
})